﻿using System;
using System.ComponentModel;

namespace HalconDotNet
{
	/// <summary>Represents an instance of a text model for text segmentations.</summary>
	// Token: 0x0200006B RID: 107
	public class HTextModel : HHandle
	{
		// Token: 0x060018F3 RID: 6387 RVA: 0x0009F403 File Offset: 0x0009D603
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HTextModel(IntPtr handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x060018F4 RID: 6388 RVA: 0x0009F412 File Offset: 0x0009D612
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HTextModel(HHandle handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x060018F5 RID: 6389 RVA: 0x0009F421 File Offset: 0x0009D621
		private void AssertSemType()
		{
			base.AssertSemType("text_model");
		}

		// Token: 0x060018F6 RID: 6390 RVA: 0x0009F42E File Offset: 0x0009D62E
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HTextModel obj)
		{
			obj = new HTextModel(HHandleBase.UNDEF);
			return obj.Load(proc, parIndex, err);
		}

		// Token: 0x060018F7 RID: 6391 RVA: 0x0009F448 File Offset: 0x0009D648
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HTextModel[] obj)
		{
			HTuple htuple;
			err = HTuple.LoadNew(proc, parIndex, err, out htuple);
			obj = new HTextModel[htuple.Length];
			for (int i = 0; i < htuple.Length; i++)
			{
				obj[i] = new HTextModel(HalconAPI.IsLegacyHandleMode() ? htuple[i].IP : htuple[i].H);
			}
			htuple.Dispose();
			return err;
		}

		/// <summary>
		///   Create a text model.
		///   Modified instance represents: New text model.
		/// </summary>
		/// <param name="mode">The Mode of the text model. Default: "auto"</param>
		/// <param name="OCRClassifier">OCR Classifier. Default: "Universal_Rej.occ"</param>
		// Token: 0x060018F8 RID: 6392 RVA: 0x0009F4B8 File Offset: 0x0009D6B8
		public HTextModel(string mode, HTuple OCRClassifier)
		{
			IntPtr proc = HalconAPI.PreCall(422);
			HalconAPI.StoreS(proc, 0, mode);
			HalconAPI.Store(proc, 1, OCRClassifier);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(OCRClassifier);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Create a text model.
		///   Modified instance represents: New text model.
		/// </summary>
		/// <param name="mode">The Mode of the text model. Default: "auto"</param>
		/// <param name="OCRClassifier">OCR Classifier. Default: "Universal_Rej.occ"</param>
		// Token: 0x060018F9 RID: 6393 RVA: 0x0009F514 File Offset: 0x0009D714
		public HTextModel(string mode, string OCRClassifier)
		{
			IntPtr proc = HalconAPI.PreCall(422);
			HalconAPI.StoreS(proc, 0, mode);
			HalconAPI.StoreS(proc, 1, OCRClassifier);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Create a text model.
		///   Modified instance represents: New text model.
		/// </summary>
		// Token: 0x060018FA RID: 6394 RVA: 0x0009F568 File Offset: 0x0009D768
		public HTextModel()
		{
			IntPtr proc = HalconAPI.PreCall(423);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Find text in an image.
		///   Instance represents: Text model specifying the text to be segmented.
		/// </summary>
		/// <param name="image">Input image.</param>
		/// <returns>Result of the segmentation.</returns>
		// Token: 0x060018FB RID: 6395 RVA: 0x0009F5AC File Offset: 0x0009D7AC
		public HTextResult FindText(HImage image)
		{
			IntPtr proc = HalconAPI.PreCall(417);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, image);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HTextResult result;
			num = HTextResult.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(image);
			return result;
		}

		/// <summary>
		///   Query parameters of a text model.
		///   Instance represents: Text model.
		/// </summary>
		/// <param name="genParamName">Parameters to be queried. Default: "min_contrast"</param>
		/// <returns>Values of Parameters.</returns>
		// Token: 0x060018FC RID: 6396 RVA: 0x0009F604 File Offset: 0x0009D804
		public HTuple GetTextModelParam(string genParamName)
		{
			IntPtr proc = HalconAPI.PreCall(418);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, genParamName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HTuple result;
			num = HTuple.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Set parameters of a text model.
		///   Instance represents: Text model.
		/// </summary>
		/// <param name="genParamName">Names of the parameters to be set. Default: "min_contrast"</param>
		/// <param name="genParamValue">Values of the parameters to be set. Default: 10</param>
		// Token: 0x060018FD RID: 6397 RVA: 0x0009F654 File Offset: 0x0009D854
		public void SetTextModelParam(HTuple genParamName, HTuple genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(419);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, genParamName);
			HalconAPI.Store(proc, 2, genParamValue);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(genParamName);
			HalconAPI.UnpinTuple(genParamValue);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Set parameters of a text model.
		///   Instance represents: Text model.
		/// </summary>
		/// <param name="genParamName">Names of the parameters to be set. Default: "min_contrast"</param>
		/// <param name="genParamValue">Values of the parameters to be set. Default: 10</param>
		// Token: 0x060018FE RID: 6398 RVA: 0x0009F6A4 File Offset: 0x0009D8A4
		public void SetTextModelParam(string genParamName, int genParamValue)
		{
			IntPtr proc = HalconAPI.PreCall(419);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, genParamName);
			HalconAPI.StoreI(proc, 2, genParamValue);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>Clear a text model.</summary>
		/// <param name="textModel">Text model to be cleared.</param>
		// Token: 0x060018FF RID: 6399 RVA: 0x0009F6E8 File Offset: 0x0009D8E8
		public static void ClearTextModel(HTextModel[] textModel)
		{
			HTuple htuple = HHandleBase.ConcatArray(textModel);
			IntPtr proc = HalconAPI.PreCall(421);
			HalconAPI.Store(proc, 0, htuple);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(htuple);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(textModel);
		}

		/// <summary>
		///   Clear a text model.
		///   Instance represents: Text model to be cleared.
		/// </summary>
		// Token: 0x06001900 RID: 6400 RVA: 0x0009F72C File Offset: 0x0009D92C
		public void ClearTextModel()
		{
			IntPtr proc = HalconAPI.PreCall(421);
			base.Store(proc, 0);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Create a text model.
		///   Modified instance represents: New text model.
		/// </summary>
		/// <param name="mode">The Mode of the text model. Default: "auto"</param>
		/// <param name="OCRClassifier">OCR Classifier. Default: "Universal_Rej.occ"</param>
		// Token: 0x06001901 RID: 6401 RVA: 0x0009F760 File Offset: 0x0009D960
		public void CreateTextModelReader(string mode, HTuple OCRClassifier)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(422);
			HalconAPI.StoreS(proc, 0, mode);
			HalconAPI.Store(proc, 1, OCRClassifier);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(OCRClassifier);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Create a text model.
		///   Modified instance represents: New text model.
		/// </summary>
		/// <param name="mode">The Mode of the text model. Default: "auto"</param>
		/// <param name="OCRClassifier">OCR Classifier. Default: "Universal_Rej.occ"</param>
		// Token: 0x06001902 RID: 6402 RVA: 0x0009F7BC File Offset: 0x0009D9BC
		public void CreateTextModelReader(string mode, string OCRClassifier)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(422);
			HalconAPI.StoreS(proc, 0, mode);
			HalconAPI.StoreS(proc, 1, OCRClassifier);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Create a text model.
		///   Modified instance represents: New text model.
		/// </summary>
		// Token: 0x06001903 RID: 6403 RVA: 0x0009F810 File Offset: 0x0009DA10
		public void CreateTextModel()
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(423);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}
	}
}
